const { system } = require("faker");

{
    let num = [];
    for (let i = 0; i < 10; i++) {
        // 做一些其他操作
        // 或者返回一些值
        num[i] = i;
    }
    console.log(num);
}

{
    let num = Array.from(new Array(10), (val, index) => {
        // 做一些其他操作
        // 或者返回一些值
        return index;
    });
    console.log(num);
}

{
    const num = [...Array(10).keys()];
    console.log(num);
}

{
    const num = (new Array(10)).fill(0);
    console.log(num);
}

{
    let iterable = {
        0: 'a',
        1: 'b',
        2: 'c',
        length: 3,
        [Symbol.iterator]: Array.prototype[Symbol.iterator] //加这它，就是个迭代器了
    };

    for (let item of iterable) {
        console.log(item);
    }
}
